﻿<ResourceDictionary
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"

  xmlns:d="clr-namespace:System.Windows.Data;assembly=PresentationFramework"
  xmlns:cm="clr-namespace:System.ComponentModel;assembly=WindowsBase"

  xmlns:controls="clr-namespace:MiniUML.View.Controls;assembly=MiniUML.View"
  xmlns:shapes="clr-namespace:MiniUML.Plugins.UmlClassDiagram.Controls.View.Shapes"
  xmlns:designItem="clr-namespace:MiniUML.View.Views.ResizeAdorner;assembly=MiniUML.View"

  xmlns:connect="clr-namespace:MiniUML.Plugins.UmlClassDiagram.Controls.View.Connect"

  xmlns:conv="clr-namespace:MiniUML.Plugins.UmlClassDiagram.Converter"
  xmlns:viewconv="clr-namespace:MiniUML.View.Converter;assembly=MiniUML.View"
  >
  <ResourceDictionary.MergedDictionaries>
    <ResourceDictionary Source="/MiniUML.Plugins.UmlClassDiagram;component/Themes/Brushes.xaml"  />

    <ResourceDictionary Source="/MiniUML.Plugins.UmlClassDiagram;component/Themes/UmlTextBox.xaml"  />
  </ResourceDictionary.MergedDictionaries>

  <Style TargetType="{x:Type shapes:UmlSquareShape}">
    <Setter Property="SnapsToDevicePixels" Value="True"/>
    <Setter Property="Width" Value="{Binding Width}" />
    <Setter Property="Height" Value="{Binding Height}" />
    <Setter Property="Template">
      <Setter.Value>
        <ControlTemplate TargetType="{x:Type shapes:UmlSquareShape}">
            <Border Background="{StaticResource ItemBrush}"
                  BorderBrush="Black"
                  BorderThickness="{TemplateBinding Property=BorderThickness}" 
              >

            <designItem:DesignerItem IsSelected="{Binding Path=IsSelected}"
                                     ResizeSelectedShapes="{Binding ResizeSelectedShapesCommand}"
                                     Background="{x:Null}" ><!-- Background=null makes inner part hittest invisible -->
              <designItem:DesignerItem.Content>

                <Grid>
              <Grid.Resources>
                <BooleanToVisibilityConverter x:Key="boolToVisConverter" />
                <conv:EmptyStringToNullConverter x:Key="emptystringToNullConverter" />
                <conv:EmptyStringToVisibilityConverter x:Key="emptystringToVisibilityConverter" />
                <conv:StringBoolToVisibilityConverter x:Key="boolToVisibilityConverter" />
              </Grid.Resources>
                <Grid.RowDefinitions>
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="*" />
              </Grid.RowDefinitions>

              <Grid.ColumnDefinitions>
                <ColumnDefinition Width="*" />
                <ColumnDefinition Width="Auto" />
              </Grid.ColumnDefinitions>

              <Grid Grid.Column="0" Grid.Row="0" VerticalAlignment="Top" HorizontalAlignment="Center">
                <Grid.RowDefinitions>
                  <RowDefinition Height="Auto" />
                  <RowDefinition Height="Auto" />
                </Grid.RowDefinitions>
                  <TextBox BorderThickness="0" Grid.Row="0"
                           FontFamily="Consola"
                           Margin="3"
                           Visibility="{Binding Path=Stereotype, Converter={StaticResource emptystringToVisibilityConverter}}"
                           Background="Transparent"
                           Foreground="Black"
                           IsTabStop="False"
                           Style="{StaticResource UmlTextBox}"
                           Text="{Binding Path=Stereotype}"
                           AcceptsReturn="False"
                           HorizontalAlignment="Center" VerticalAlignment="Top"
                         />

                <TextBox BorderThickness="0" Grid.Row="1"
                         FontFamily="Consola"
                         Margin="3"
                         Background="Transparent"
                         Foreground="Black"
                         IsTabStop="False"
                         Style="{StaticResource UmlTextBox}"
                         Text="{Binding Path=Name}"
                         AcceptsReturn="False"
                         HorizontalAlignment="Center" VerticalAlignment="Top"
                       />
              </Grid>

              <Image Source="{Binding Path=ShapeImageUrl,Converter={StaticResource emptystringToNullConverter}}"                      
                     Visibility="{Binding Path=ShapeImageUrl, Converter={StaticResource emptystringToVisibilityConverter}}"
                     Grid.Column="1" Grid.Row="0"
                     HorizontalAlignment="Center"
                     VerticalAlignment="Center"
                     Margin="3"/>

              <Border Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="2"
                      Visibility="{Binding Path=HorizontalLine, Converter={StaticResource boolToVisibilityConverter}}"
                      Background="{StaticResource ItemBrush}"
                      BorderThickness="0,1,0,0"
                      BorderBrush="Black"
                      HorizontalAlignment="Stretch" VerticalAlignment="Center" Margin="0" />
              <!-- Stroke="Black" StrokeThickness="4" -->

            </Grid>

              </designItem:DesignerItem.Content>
            </designItem:DesignerItem>
          </Border>

          <ControlTemplate.Triggers>
            <Trigger Property="IsMouseOver" Value="True">
              <Setter Property="Cursor" Value="Hand"/>
            </Trigger>
          </ControlTemplate.Triggers>
        </ControlTemplate>
      </Setter.Value>
    </Setter>
  </Style>

</ResourceDictionary>
